﻿using PropertyExpression.TypedDataBinding.Wpf.Controls;

namespace PropertyExpression.TypedDataBinding.Wpf
{
    /// <summary>
    /// Interaction logic for Window1.xaml
    /// </summary>
    public partial class Window1
    {
        private readonly Person person = new Person();

        private readonly Binder<Person> personBinder = new Binder<Person>();

        public Window1()
        {
            DataContext = person;

            InitializeComponent();
        }

        private void label1_TypedInit(Label s)
        {
            s.SetBinding(ContentProperty,
                         personBinder.GetBinding(
                             c => new
                                      {
                                          FirstName = c.Reg(x => x.FirstName),
                                          LastName = c.Reg(x => x.LastName)
                                      },
                             x => string.Format("{0} {1}", x.FirstName, x.LastName).ToUpper()));
        }
    }
}